/*
  ID: nemokin1
  PROG: beads
  LANG: C++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
 
using namespace std;
 
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
 
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a)  (int(a.size()))
 
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef long double ld;
const int INF = 1000000000;

int main() {
    //freopen("beads.in","r",stdin);freopen("beads.out","w",stdout);
    int ret = 0;
    string s;
    int N;
    cin >> N;
    cin >> s;
    s+=s;
    int rl[800];
    int rr[800];
    int bl[800];
    int br[800];
    bl[0] = rl[0] = 0;
    FOR(i,1,2*N){
	if(s[i-1] == 'w') {bl[i]=bl[i-1]+1;rl[i]=rl[i-1]+1;}
	else if(s[i-1] == 'r'){
	    bl[i] = 0;
	    rl[i] = rl[i-1]+1;
	}
	else{
	    rl[i] = 0;
	    bl[i] = bl[i-1]+1;
	}
    }
    br[2*N] = rr[2*N] = 0;
    for(int i = 2*N-1; i >= 0; i--){
	if(s[i] == 'w'){
	    br[i] = br[i+1]+1;
	    rr[i] = rr[i+1]+1;
	}
	else if(s[i] == 'r'){
	    rr[i] = rr[i+1]+1;
	    br[i] = 0;
	}
	else{
	    rr[i] = 0;
	    br[i] = br[i+1] + 1;
	}
    }
    ////////////////////////////////////////////////////////
    // REP(i,2*N+1){					  //
    // 	cerr<<"bl["<<i<<"]"<<": "<<bl[i]<<endl;		  //
    // 	cerr<<"rl["<<i<<"]"<<": "<<rl[i]<<endl;		  //
    // 	cerr<<"br["<<i<<"]"<<": "<<br[i]<<endl;		  //
    // 	cerr<<"rr["<<i<<"]"<<": "<<rr[i]<<endl;		  //
    // }						  //
    ////////////////////////////////////////////////////////
    REP(i,2*N){
	checkMax(ret,max(rl[i],bl[i])+max(rr[i],br[i]));
    }
    if(ret>N) cout<<N<<endl;
    else
	cout<<ret<<endl;
    exit(0);
}
